/**
 * @author YangTao
 * @date 2025/4/18
 */
package com.tian.source.controller;

import com.tian.core.beans.ResultBean;
import com.tian.source.model.User;
import com.tian.source.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping(value = "/user")
public class UserController {

    @Autowired
    private UserService userService;

    /**
     * 获取用户信息
     */
    @GetMapping("/getUserInfo")
    public ResultBean<User> findUserInfo(Integer uid){
        User user = userService.findById(uid);
        return new ResultBean<>(user);
    }

    /**
     * 修改用户密码
     * @param userId
     * @param password
     * @return
     */
    @PostMapping("/updatePasswd")
    public ResultBean<String> updatePwd(Integer userId,String password){
        userService.updatePwd(userId, password);
        return new ResultBean<>("修改成功");
    }
}
